package com.angel.provider.health.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.angel.core.base.BaseProviderImpl;
import com.angel.core.util.Pager;
import com.angel.dao.health.BuzExceptionMapper;
import com.angel.health.BuzException;
import com.angel.provider.health.BuzExceptionProvider;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class BuzExceptionProviderImpl extends BaseProviderImpl<BuzException> implements BuzExceptionProvider {

	@Autowired
	private BuzExceptionMapper mapper;
	
	@Override
	public BuzException findById(Integer id) {
		return mapper.selectByPrimaryKey(id);
	}

	@Override
	public int deleteByKeysSelective(List<Integer> ids) {
		return mapper.updateByKeysSelective(ids);
	}

	@Override
	public Pager findAll(BuzException record, Pager pager) {
		PageHelper.startPage(pager.getCurrentPage(), pager.getPageSize());
		
		List<Map<String, Object>> list = mapper.findAllByParam(record, pager);
		
		PageInfo<Map<String, Object>> pageInfo = new PageInfo<Map<String, Object>>(list);
		
		pager.setTotal(pageInfo.getTotal());
		pager.setTotalPages(pageInfo.getPages());
		pager.setList(pageInfo.getList());
		return pager;
	}

}
